<?php

class Notatki extends CI_Controller {

    function index() {

    }

    function download($file) {
        $this->load->helper('download');
        $data = file_get_contents('./uploads/' . $file); // Read the file's contents
        $name = 'super.zip';

        force_download($name, $data);
    }

    function __construct() {
        parent::__construct();
        $this->load->helper(array('form', 'url', 'language'));
        $this->lang->load(array('general'));
    }

//    function __construct() {
//        parent::__construct();
//
//        // Load the necessary stuff...
//        $this->load->helper(array('language', 'url', 'form', 'account/ssl'));
////        $this->load->library(array('account/authentication'));
//        $this->load->model(array('account/account_model', 'kierunek_model'));
//        $this->lang->load(array('general'));
//    }

    function upload() {
        $data['main_content'] = 'upload';
        $data['title'] = 'Wrzucanie notatek';
        $this->load->view('includes/template', $data);
    }

    public function do_upload() {
        $config['upload_path'] = $this->config->item('upload_dir');
        $config['allowed_types'] = '*';
        $config['max_size'] = '300000000';
        $config['encrypt_name'] = TRUE;

        $this->load->library('upload', $config);

        if (!$this->upload->do_upload('file')) {
//            $error = array('error' => $this->upload->display_errors());
//            $this->load->view('form', $error);
        }
//        else {
//            $data['upload_data'] = $this->upload->data();
//            $this->load->view('success', $data);
//        }
        $response = "";
//        foreach($_REQUEST as $key => $value){
//            $response.="<b>" . $key . "</b> : " . $value . "<br/>";
//        }
        foreach ($_SERVER as $key => $value) {
            $response.="<b>" . $key . "</b> : " . $value . "<br/>";
        }
        echo $response;
    }

    public function update() {
        
    }

}

?>
